$(function () {
    let form = layui.form
        ,laydate = layui.laydate,
        laypage = layui.laypage,
        layer = layui.layer,
        table = layui.table;
    //常规用法
    laydate.render({
        elem: '#test1'
    });
    laydate.render({
        elem: '#test2'
    });




    let i=1,j=1,k=1;
    $('.add-btn').click(function () {
        i++;
        addstrs1(i);
        form.render();
    });

    $('body').on("click",".btn-del",function () {
         var pre = $(this);
        layer.confirm('确定要删除么？',{
                btn:['确定','取消']
        },function () {
            $(pre).parent().parent().remove();
            layer.closeAll('dialog');
        })

        //
    });


    function getRandomNum() {
        return parseInt(Math.random()*50);
    }
    function addstrs1(i) {
        let  iNums = getRandomNum();
        let strs1;
             strs1 = '<tr>\n' +
                 '                            <td>\n' +
                 '                                <select name="default_field[type][]" lay-filter="" lay-verify="required">\n' +
                 '                                    <option value="">请选择字段类型</option>\n' +
                 '                                     <option value="input" >单行输入框[input]</option>\n' +
                 '                                     <option value="textarea" >多行输入框[textarea]</option>\n' +
                 '                                     <option value="select" >下拉选项[select]</option>\n' +
                 '                                     <option value="radio" >单选按钮[radio]</option>\n' +
                 '                                     <option value="upload" >图片上传[upload]</option>\n' +
                 '                                     <option value="editor" >编辑器[editor]</option>\n' +
                 '                                     <option value="photo" >多图上传[photo]</option>\n' +
                 '                                     <option value="date" >日期[date]</option>\n' +
                 '                                     <option value="date_range" >日期区间[date_range]</option>\n' +
                 '                                     <option value="shengshi" >省市联动[shengshi]</option>\n' +
                 '                                     <option value="dict" >绑定字典[dict]</option>\n' +
                 '                                </select>\n' +
                 '                            </td>\n' +
                 '                            <td>\n' +
                 '                                <input type="text"  name="default_field[title][]" class="layui-input" lay-verify="required">\n' +
                 '                            </td>\n' +
                 '                            <td>\n' +
                 '                                <input type="text" name="default_field[name][]" class="layui-input" lay-verify="required">\n' +
                 '                            </td>\n' +
                 '                            <td>\n' +
                 '                                <input type="text" name="default_field[value][]" class="layui-input">\n' +
                 '                            </td>\n' +
                 '                            <td>\n' +
                 '                                <select name="default_field[is_sys][]" lay-verify="required">\n' +
                 '                                    <option value="">请选择</option>\n' +
                 '                                    <option value="0">否</option>\n' +
                 '                                    <option value="1">是</option>\n' +
                 '                                </select>\n' +
                 '                            </td>\n' +
                 '                            <td style="text-align: center"><button type="button" class="layui-btn layui-btn-sm layui-btn-danger btn-del">删除</button></td>\n' +
                 '                        </tr>';
        $('.addlists').append(strs1);
        //重新渲染
        laydate.render({
            elem: '#test1'+iNums
            ,trigger: 'click' //采用click弹出
        });
        laydate.render({
            elem: '#test2'+iNums
            ,trigger: 'click' //采用click弹出
        });
    }



})
